package cn.wsalix.msg.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.anlaser.service.impl.CommonServiceImpl;
import cn.anlaser.utils.SearchFilter;
import cn.anlaser.utils.SearchFilter.Operator;
import cn.wsalix.msg.entity.NoticeRecord;
import cn.wsalix.msg.repository.NoticeRecordRepository;
import cn.wsalix.msg.service.NoticeRecordService;
import cn.wsalix.user.form.NoticeRecordForm;

@Service("noticeRecordService")
public class NoticeRecordServiceImpl
		extends
		CommonServiceImpl<NoticeRecordForm, NoticeRecordRepository, NoticeRecord>
		implements NoticeRecordService {
	@Autowired
	private NoticeRecordRepository noticeRecordRepository;

	@Override
	public String module() {
		return "/admin/notice_record";
	}

	@Override
	public NoticeRecordRepository getRepository() {
		return noticeRecordRepository;
	}

	@Override
	public Class<NoticeRecord> getEntityClazz() {
		return NoticeRecord.class;
	}

	@Override
	public Map<String, SearchFilter> buildByForm(NoticeRecordForm form) {
		Map<String, Object> searchParams = new HashMap<String, Object>();
		Map<String, SearchFilter> filters = SearchFilter.parse(searchParams);
		if (form.getName() != null && !form.getName().trim().equals("")) {
			filters.put("name",
					new SearchFilter("name", Operator.LIKE, form.getName()));
		}
		return filters;
	}

}
